<?php

namespace App\Http\Validate\WorkOrder;

use App\Enums\WorkOrder\MissionEnum;
use App\Http\Validate\AbstractBaseValidate;
use App\Models\WorkOrder\WorkOrderApplyMainModel;
use Illuminate\Support\MessageBag;
use Illuminate\Validation\Rule;
use Illuminate\Validation\ValidationException;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;

class WorkOrderValidate extends AbstractBaseValidate
{
    function getRules(): array
    {
        // TODO: Implement getRules() method.
        return [];
    }

    function getAttributes(): array
    {
        // TODO: Implement getAttributes() method.
        return [];
    }

    function registerValidateRules(): void
    {
        // TODO: Implement registerValidateRules() method.
    }

    function getMessages(): array
    {
        // TODO: Implement getMessages() method.
        return [];
    }

    /**
     * @param array $params
     * @return MessageBag|object
     * @throws ValidationException
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public static function merchantConfirmFinishValidate(array $params)
    {
        return self::getInstance()->validate(
            ["workOrderNo"],
            $params,
            [
                "workOrderNo" => [
                    "string",
                    "required",
                    Rule::exists((new WorkOrderApplyMainModel())->getTable(), "workOrderNo")
                        ->where("step", MissionEnum::STEP_99)
                ]
            ]
        );
    }
}
